package xiaoqi.springboot.boot.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Primary
    @Bean(name = "user1DataSource")
    @ConfigurationProperties(prefix = "spring.datasource.user1")
    public DataSource user1DataSource() {
        return DruidDataSourceBuilder.create().build();
    }

    @Bean(name = "user2DataSource")
    @ConfigurationProperties(prefix = "spring.datasource.user2")
    public DataSource user2DataSource() {
        return DruidDataSourceBuilder.create().build();
    }

}
